//---------------------------------------------------------------------------

#ifndef poseH
#define poseH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Buttons.hpp>
#include <Dialogs.hpp>
#include <Menus.hpp>
#include <Grids.hpp>
#include <jpeg.hpp>
#include "pies.h"
#include <ComCtrls.hpp>

typedef enum
{
	ADULT = 0, // Addult David I
	KID_FIRA = 1,
	KID_ROBOCUP = 2,
	ANDROSOT = 3,
	DavidII = 4, // Addult David II
	KID_FIRA_2014 = 5,
	TEEN_FIRA_2014 = 6
} RoboTypeStatus;

#define TORQUE_BASE_OLD 30
#define TORQUE_BASE_NEW 50
#define ID_MAX					256

//---------------------------------------------------------------------------
class TFormPose : public TForm
{
__published:	// IDE-managed Components
	TButton *Button_ok;
	TButton *Button_cancle;
	TButton *Button_all;
	TButton *Button_check;
	TButton *ButtonOpen;
	TButton *ButtonSave;
	TPageControl *PageControl_Config;
	TTabSheet *TabSheet1;
	TTabSheet *TabSheet2;
	TOpenDialog *OpenDialog1;
	TSaveDialog *SaveDialog1;
	TTimer *Timer1;
	TTimer *Timer_UpdateBattery;
	TTimer *Timer_rd;
	TTimer *Timer_send;
	TGroupBox *GroupBoxMotorConfig;
	TLabel *Label2;
	TLabel *Label3;
	TLabel *Label4;
	TLabel *Label_GBs;
	TComboBox *ComboBox_MotorDir;
	TComboBox *ComboBox_PartDriven;
	TEdit *Edit_MotorID;
	TEdit *Edit_MotorRPM;
	TImage *Image1;
	TGroupBox *GroupBoxATNJ;
	TShape *Shape24;
	TShape *Shape25;
	TPie *Pie_NextJointAngle;
	TLabel *Label6;
	TLabel *Label8;
	TLabel *Label7;
	TEdit *Edit_NextJointAngle;
	TLabel *Label9;
	TLabel *Label10;
	TComboBox *ComboBox_Battery;
	TGroupBox *GroupBoxLR;
	TButton *ButtonSyncLR;
	TTabSheet *TabSheet3;
	TGroupBox *GroupBoxKB_LeftLeg;
	TButton *Button17;
	TButton *Button24;
	TButton *Button23;
	TButton *Button18;
	TGroupBox *GroupBoxKB_RightLeg;
	TButton *Button19;
	TButton *Button28;
	TButton *Button26;
	TButton *Button20;
	TGroupBox *GroupBoxKB_Coronal;
	TButton *Button30;
	TButton *Button12;
	TButton *Button6;
	TButton *Button4;
	TButton *Button10;
	TButton *Button2;
	TButton *Button1;
	TButton *Button9;
	TButton *Button3;
	TButton *Button31;
	TGroupBox *GroupBoxKB_Sagittal;
	TButton *Button16;
	TButton *Button15;
	TButton *Button_L;
	TButton *Button13;
	TButton *Button14;
	TButton *Button_R;
	TGroupBox *GroupBox25;
	TLabel *Label1;
	TComboBox *ComboBoxNum;
	TLabel *Label5;
	TComboBox *ComboBox_LegType;
	TSaveDialog *SaveDialogEdit;
	TButton *ButtonSaveEditPage;
	TButton *ButtonOpenEditPage;
	TOpenDialog *OpenDialogEdit;
	TGroupBox *GroupBox1;
	TComboBox *ComboBoxRoboType;
	TButton *Button_SetConfig;
	TLabel *Label11;
	TEdit *Edit_MC_No;
	TLabel *Label12;
	TEdit *Edit_MC_Top;
	TLabel *Label13;
	TEdit *Edit_MC_Left;
	TButton *Button_HideAllMotor;
	TCheckBox *CheckBox_HideAllMotor;
	TComboBox *ComboBox_Joint;
	TButton *Button7;
	TButton *Button8;
	TButton *Button11;
	TButton *Button5;
	TButton *ButtonGenerate;
	TSaveDialog *SaveDialogConfig;
	TGroupBox *GroupBoxStatus;
	TLabel *V1;
	TLabel *V2;
	TLabel *V3;
	TStaticText *StaticText24;
	TStaticText *StaticText25;
	TStaticText *StaticText26;
	TComboBox *ComboBox_Type;
	TButton *Button_BoxShow;
	TCheckBox *CheckBox_MCEnabled;
	void __fastcall Timer1Timer(TObject *Sender);
	void __fastcall FormCreate(TObject *Sender);
	void __fastcall Timer_UpdateBatteryTimer(TObject *Sender);
	void __fastcall Button_okClick(TObject *Sender);
	void __fastcall Button_cancleClick(TObject *Sender);
	void __fastcall Button_allClick(TObject *Sender);
	void __fastcall Button_checkClick(TObject *Sender);
	void __fastcall FormHide(TObject *Sender);
	void __fastcall Timer_sendTimer(TObject *Sender);
	void __fastcall Timer_rdTimer(TObject *Sender);
	void __fastcall ButtonSyncLRClick(TObject *Sender);
	void __fastcall FormShow(TObject *Sender);
	void __fastcall ButtonOpenClick(TObject *Sender);
	void __fastcall ButtonSaveClick(TObject *Sender);
	void __fastcall Edit_MotorIDKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall Edit_MotorRPMKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall ComboBox_MotorDirChange(TObject *Sender);
	void __fastcall ComboBox_PartDrivenChange(TObject *Sender);
	void __fastcall ComboBox_LegTypeChange(TObject *Sender);
	void __fastcall Button_SetConfigClick(TObject *Sender);
	void __fastcall Edit_NextJointAngleKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall Pie_NextJointAngleMouseDown(TObject *Sender, TMouseButton Button,
          TShiftState Shift, int X, int Y);
	void __fastcall ComboBox_BatteryChange(TObject *Sender);
	void __fastcall GroupBoxMotorDblClick(TObject *Sender);

	void __fastcall FormDragOver(TObject *Sender, TObject *Source, int X, int Y, TDragState State,
          bool &Accept);
	void __fastcall ButtonSaveEditPageClick(TObject *Sender);
	void __fastcall Edit_MC_NoKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall Edit_MC_TopKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall Edit_MC_LeftKeyPress(TObject *Sender, wchar_t &Key);
	void __fastcall ButtonOpenEditPageClick(TObject *Sender);
	void __fastcall ComboBoxRoboTypeChange(TObject *Sender);
	void __fastcall FormDestroy(TObject *Sender);
	void __fastcall ComboBoxNumChange(TObject *Sender);
	void __fastcall CheckBox_HideAllMotorClick(TObject *Sender);
	void __fastcall Button_HideAllMotorClick(TObject *Sender);
	void __fastcall ComboBox_JointChange(TObject *Sender);
	void __fastcall ButtonGenerateClick(TObject *Sender);
	void __fastcall Button2Click(TObject *Sender);
	void __fastcall Button1Click(TObject *Sender);
	void __fastcall Button4Click(TObject *Sender);
	void __fastcall Button3Click(TObject *Sender);
	void __fastcall Button10Click(TObject *Sender);
	void __fastcall Button9Click(TObject *Sender);
	void __fastcall Button5Click(TObject *Sender);
	void __fastcall Button6Click(TObject *Sender);
	void __fastcall Button8Click(TObject *Sender);
	void __fastcall Button7Click(TObject *Sender);
	void __fastcall Button12Click(TObject *Sender);
	void __fastcall Button11Click(TObject *Sender);
	void __fastcall Button13Click(TObject *Sender);
	void __fastcall Button14Click(TObject *Sender);
	void __fastcall Button16Click(TObject *Sender);
	void __fastcall Button15Click(TObject *Sender);
	void __fastcall Button_RClick(TObject *Sender);
	void __fastcall Button_LClick(TObject *Sender);
	void __fastcall Button19Click(TObject *Sender);
	void __fastcall Button20Click(TObject *Sender);
	void __fastcall Button17Click(TObject *Sender);
	void __fastcall Button18Click(TObject *Sender);
	void __fastcall Button30Click(TObject *Sender);
	void __fastcall Button31Click(TObject *Sender);
	void __fastcall Button28Click(TObject *Sender);
	void __fastcall Button26Click(TObject *Sender);
	void __fastcall Button24Click(TObject *Sender);
	void __fastcall Button23Click(TObject *Sender);
	void __fastcall ComboBox_TypeChange(TObject *Sender);
	void __fastcall Button_BoxShowClick(TObject *Sender);

private:	// User declarations

public:		// User declarations
	__fastcall TFormPose(TComponent* Owner);
	void Load_Config(int GroupBox_ID);
	void Delay(DWORD DT);
	int bound_int(int data, int bottom, int top);
	void send(unsigned char com[5]);

	void SetMC_Config_Adult();
	void SetMC_Config_Kid();
	void SetMC_Config_AndroSot();
	void SetMC_Config_DavidII();
	void SetMC_Config_Kid_FIRA2014();
	void SetMC_Config_Teen_FIRA2014();

	void SetRobot_Config_FIRA();
	void SetRobot_Config_RoboCup();
	void SetRobot_Config_DavidII();
	void SetRobot_Config_Kid_FIRA2014();
	void SetRobot_Config_Teen_FIRA2014();
};
//---------------------------------------------------------------------------
extern PACKAGE TFormPose *FormPose;
//---------------------------------------------------------------------------
#endif
